package com.fuxi.cloud.desreport.service.a;

import com.fuxi.cloud.common.vo.JmDictModel;
import com.fuxi.cloud.desreport.dao.JimuReportDictDao;
import com.fuxi.cloud.desreport.dao.JimuReportDictItemDao;
import com.fuxi.cloud.desreport.entity.JimuReportDict;
import com.fuxi.cloud.desreport.model.JmPage;
import com.fuxi.cloud.desreport.service.IJimuReportDictService;
import org.jeecgframework.minidao.pojo.MiniDaoPage;
import org.jeecgframework.minidao.util.SnowflakeIdWorker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * a
 *
 * @Author: 扫地僧
 * @CreateTime: 2021-05-03
 */
@Service("jimuDictServiceImpl")
public class b implements IJimuReportDictService {
    private static final Logger a = LoggerFactory.getLogger(b.class);
    @Autowired
    private JimuReportDictDao reportDictDao;
    @Autowired
    private JimuReportDictItemDao reportDictItemDao;

    public b() {
    }

    @Override
    @Cacheable(
            value = {"jmreport:cache:dict"},
            key = "#code",
            unless = "#result == null || #result.size()==0"
    )
    public List<JmDictModel> queryDictItemsByCode(String code, String username) {
        a.info("无缓存dictCache的时候调用这里！");
        List var3 = this.reportDictDao.queryDictItemsByCode(code);
        return var3;
    }

    @Override
    @Cacheable(
            value = {"jmreport:cache:dictTxt"},
            key = "#code+':'+#key",
            unless = "#result == null"
    )
    public String queryDictTextByKey(String code, String key) {
        a.info("无缓存dictText的时候调用这里！");
        return this.reportDictDao.queryDictTextByKey(code, key);
    }

    @Override
    public Integer getDictCount(String dictCode) {
        return this.reportDictDao.getDictCount(dictCode);
    }

    @Override
    public Integer getEditDictCount(String dictCode, String id) {
        return this.reportDictDao.getEditDictCount(dictCode, id);
    }

    @Override
    public List<JimuReportDict> queryDeleteList(String username) {
        return this.reportDictDao.queryDeleteList(username);
    }

    @Override
    public int updateDictDelFlag(Integer delFlag, String id) {
        return this.reportDictDao.updateDictDelFlag(delFlag, id);
    }

    @Override
    public void deleteOneDictPhysically(String id) {
        this.reportDictDao.deleteById(id);
        this.reportDictItemDao.deleteByDictId(id);
    }

    @Override
    public JmPage<JimuReportDict> queryPageList(JimuReportDict report, Integer pageNo, Integer pageSize) {
        MiniDaoPage var4 = this.reportDictDao.getAll(report, pageNo, pageSize);
        JmPage var5 = com.fuxi.cloud.desreport.b.b.a(var4);
        return var5;
    }

    @Override
    public void save(JimuReportDict reportDict) {
        reportDict.setId(String.valueOf(SnowflakeIdWorker.generateId()));
        this.reportDictDao.insert(reportDict);
    }

    @Override
    public JimuReportDict getById(String id) {
        return this.reportDictDao.get(id);
    }

    @Override
    public Integer updateById(JimuReportDict reportDict) {
        return this.reportDictDao.update(reportDict);
    }

    @Override
    public void updateDelFlagByIds(String ids) {
        this.reportDictDao.updateDelFlagByIds(ids);
    }
}

